<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据接口</title>
    <script type="text/javascript">
    var xmlhttp;
        function createXMLHTTPRequest()
        {
            if(window.ActiveXObject)
            {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            else if(window.XMLHttpRequest)
            {
                xmlhttp= new XMLHttpRequest();
            }
            else
            {
                alert("your browser does not support XMLHTTP")
            }
        }

        function getInfo()
        {
            createXMLHTTPRequest();
            xmlhttp.open("GET","http://op.juhe.cn/yi18/news/list?key=323a3706705a1fc62d516f63b7e226dd",true);
            xmlhttp.onreadystatechange=returnInfo;
            xmlhttp.send(null);
        }
//        var heytitle,heytext;
        function returnInfo()
        {
            if(xmlhttp.readyState==4)
            {
                if(xmlhttp.status==200){
                    var info=xmlhttp.responseText;
//                eval("var json="+info);
                    var myjson=eval('('+info+')');
//                var heytitle=myjson.list[0].title;
//                var heytitle=myjson[0].title;
                    var heytext=myjson.result.list[0].description;
//                document.getElementById("mytitle").childNodes[0].nodeValue=heytitle;
                    document.getElementById("mytext").childNodes[0].nodeValue=heytext;
                }

            }
        }

//        document.getElementById("mytitle").childNodes[0].nodeValue=heytitle;
//        document.getElementById("mytext").childNodes[0].nodeValue=heytext;

    </script>

</head>
<body onload="getInfo()">
<h1>异步调用json</h1>
<div>
    <span id="mytitle"></span>
</div>
<div>
    <p id="mytext"></p>
</div>
</body>
</html>